package wykop.analyze;

import com.google.common.base.CharMatcher;
import com.google.common.base.Predicate;
import com.google.common.base.Splitter;

public class WordBreaker {

	private static boolean isSeparator(final char c) {
		if (Character.isLetterOrDigit(c)) {
			return false;
		} else if (c == '@') {
			return false;
		} else if (c == '$') {
			return false;
		} else if (c == '%') {
			return false;
		}

		return true;

	}

	public static Iterable<String> tokens(final String sentence) {

		final Predicate<Character> isSeparator = new Predicate<Character>() {

			@Override
			public boolean apply(final Character input) {
				return isSeparator(input);
			}

		};
		final CharMatcher cm = CharMatcher.forPredicate(isSeparator);
		return Splitter.on(cm).trimResults().omitEmptyStrings().split(sentence);
	}

}
